package com.mars.module.admin.entity;

import java.util.ArrayList;
import java.util.List;

public class User {
    public String username;
    public List<NewsScore> newsScoreList = new ArrayList<>();

    public User() {
    }

    public User(String username) {
        this.username = username;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public User set(String newsTitle, int score, Long newsId) {
        this.newsScoreList.add(new NewsScore(newsTitle, score, newsId));
        return this;
    }

    public NewsScore find(String newsTitle) {
        for (NewsScore NewsScore : newsScoreList) {
            if (NewsScore.newsTitle.equals(newsTitle)) {
                return NewsScore;
            }
        }
        return null;
    }

    @Override
    public String toString() {
        return "User{" +
                "username='" + username + '\'' +
                '}';
    }
}

